/*--------------------------------------------------------------------------
Header file for PMICRO microcontroller.
--------------------------------------------------------------------------*/

#ifndef __REG51_H__
#define __REG51_H__

//BYTE Register
sfr ACC   	= 0xE0;
sfr B				= 0xF0;
sfr PSW   	= 0xD0;
sfr SP			= 0x81;
sfr DPL			= 0x82;
sfr DPH    	= 0x83;
sfr CKCON		= 0x8E;
sfr TA	   	= 0xFF;
sfr SRST    = 0xF7;
sfr SCKCON	= 0x96;
sfr RSTCON	= 0xF8;
sfr PCON  	= 0x87;

//Interrupt
sfr IE0			= 0xA8;
sfr IE1			= 0xB8;
sfr IRCON		= 0xC0;
sfr IP0			= 0xA9;
sfr IP0H  	= 0xB1;
sfr IP1			= 0xB9;
sfr IP1H  	= 0xC1;

//Keyboard
sfr KBCON 	= 0xBC;

//Port
sfr P0			= 0x80;
sfr P0M0		= 0xB2;
sfr P0M1		= 0xB3;
sfr P1			= 0x90;
sfr P1M0		= 0xB4;
sfr P1M1		= 0xB5;
sfr P2			= 0xA0;
sfr P2M0		= 0xB6;
sfr P2M1		= 0xB7;
sfr ASW0		= 0xAC;
sfr ASW1		= 0xAD;
sfr PSFT		= 0xAE;
sfr PSFT1		= 0xAF;

//Timer
sfr TCON  	= 0x88;
sfr TMOD  	= 0x89;
sfr TCKCON	= 0x8F;
sfr TH0   	= 0x8C;
sfr TL0			= 0x8A;
sfr TH1			= 0x8D;
sfr TL1		  = 0x8B;
sfr T2CON 	= 0xC8;
sfr T2MOD 	= 0xC9;
sfr CRCH  	= 0xCB;
sfr CRCL  	= 0xCA;
sfr TH2   	= 0xCD;
sfr TL2			= 0xCC;

//PWM
sfr PWMCON 	= 0xFA;
sfr PWMCON1 = 0xF9;
sfr PWM0PH 	= 0xFC;
sfr PWM0PL 	= 0xFB;
sfr PWM0DH 	= 0xFE;
sfr PWM0DL 	= 0xFD;
sfr PWM1PH 	= 0xF4;
sfr PWM1PL 	= 0xF3;
sfr PWM1DH 	= 0xF6;
sfr PWM1DL 	= 0xF5;
sfr PWM2PH 	= 0xE9;
sfr PWM2PL 	= 0xE8;
sfr PWM2DH 	= 0xEB;
sfr PWM2DL 	= 0xEA;
sfr PWM3PH 	= 0xED;
sfr PWM3PL 	= 0xEC;
sfr PWM3DH 	= 0xEF;
sfr PWM3DL 	= 0xEE;

//WDT
sfr WDTCON 	= 0x86;

//UART SPI I2C
sfr SCON  	= 0x98;
sfr SBUF  	= 0x99;
sfr SPSTA		= 0xE1;
sfr SPCON		= 0xE2;
sfr SPDAT		= 0xE3;
sfr I2CSTA	= 0xDD;
sfr I2CCON	= 0xDC;
sfr I2CADR	= 0xDB;
sfr I2CDAT	= 0xDA;

//Touch key
sfr TKDATL	= 0xA1;
sfr TKDATH  = 0xA2;
sfr TKCHS0  = 0xA3;
sfr TKCHS1  = 0xA4;
sfr TKCON0	= 0xA5;
sfr TKCON1	= 0xA6;
sfr TKCON2	= 0xA7;
sfr TKADCF  = 0x9D;
sfr TKCSCF  = 0x9E;
sfr TKCSOF	= 0x9F;
sfr TKWKL0	= 0xD2;
sfr TKWKH0	= 0xD3;
sfr TKWKL1	= 0xD4;
sfr TKWKH1	= 0xD5;

//Compare
sfr CMPCON0	= 0xBD;
sfr CMPCON1	= 0xBE;

//
sfr EECON		= 0x97;
sfr TREGC 	= 0xE6;
sfr TREGD 	= 0xE7;

//ADC
sfr ADCCON  = 0xBA;
sfr ADCSEL  = 0xBB;
sfr ADCDATL = 0xC2;
sfr ADCDATH = 0xC3;

//Bit Register
//PSW
sbit CY		= 0xD7;
sbit AC		= 0xD6;
sbit F0		= 0xD5;
sbit RS1	= 0xD4;
sbit RS0	= 0xD3;
sbit OV		= 0xD2;
sbit f1		= 0xD1;
sbit P		= 0xD0;
//TCON
sbit TF1	= 0x8F;
sbit TR1	= 0x8E;
sbit TF0	= 0x8D;
sbit TR0	= 0x8C;
sbit IT1	= 0x8A;
sbit IT0	= 0x88;
//SCON
sbit SM0	= 0x9F;
sbit SM1	= 0x9E;
sbit SM2	= 0x9D;
sbit REN	= 0x9C;
sbit TB8	= 0x9B;
sbit RB8	= 0x9A;
sbit TI		= 0x99;
sbit RI		= 0x98;
//IECON0
sbit EA		= 0xAF;
sbit ET2	= 0xAD;
sbit ES0	= 0xAC;
sbit ET1	= 0xAB;
sbit EX1	= 0xAA;
sbit ET0	= 0xA9;
sbit EX0	= 0xA8;
//IECON1
sbit ET2R	= 0xBF;
sbit ETK	= 0xBD;
sbit EKB	= 0xBC;
sbit ET2C	= 0xBB;
sbit ECMP	= 0xBA;
sbit ESPI	= 0xB9;
sbit EI2C	= 0xB8;
//T2CON
sbit T2EN	= 0xCF;
sbit AES1	= 0xCE;
sbit AES0	= 0xCD;
sbit T2R1	= 0xCC;
sbit T2R0	= 0xCB;
sbit T2CM	= 0xCA;	  
//RSTCON
sbit FCHK	= 0xFD;
sbit LPDF	= 0xFC;
sbit PORF	= 0xFB;
sbit LVRF	= 0xFA;
sbit EXRF	= 0xF9;
sbit WDRF	= 0xF8;
//
sbit P00 = P0^0;
sbit P01 = P0^1;
sbit P02 = P0^2;
sbit P03 = P0^3;
sbit P04 = P0^4;
sbit P05 = P0^5;
sbit P10 = P1^0;
sbit P11 = P1^1;
sbit P12 = P1^2;
sbit P13 = P1^3;
sbit P14 = P1^4;
sbit P15 = P1^5;
sbit P16 = P1^6;
sbit P17 = P1^7;
sbit P20 = P2^0;
sbit P21 = P2^1;
sbit P22 = P2^2;
sbit P23 = P2^3;
sbit P24 = P2^4;
sbit P25 = P2^5;
sbit P26 = P2^6;
sbit P27 = P2^7;


#define BIT0 0x01
#define BIT1 0x02
#define BIT2 0x04
#define BIT3 0x08
#define BIT4 0x10
#define BIT5 0x20
#define BIT6 0x40
#define BIT7 0x80


#ifndef uint8_t
#define uint8_t unsigned char
#endif

#ifndef uint16_t
#define uint16_t unsigned int
#endif

#ifndef uint32_t
#define uint32_t unsigned long
#endif


#endif

